# Copyright (c) 2009 XORP, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, Version 2, June
# 1991 as published by the Free Software Foundation. Redistribution
# and/or modification of this program under the terms of any other
# version of the GNU General Public License is not permitted.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
# see the GNU General Public License, Version 2, a copy of which can be
# found in the XORP LICENSE.gpl file.
#
# XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
# http://xorp.net

# $XORP$

import os
Import('env')

subdirs = [
	#'harness',
	'tests',
	'tools',
    ]

SConscript(dirs = subdirs, exports='env')

env = env.Clone()

# XXX Not used, bgp linkage must remain static until we fix the
# dependency graph in here.
#is_shared = env.has_key('SHAREDLIBS')

env.AppendUnique(CPPPATH = [
    '#',
    '$BUILDDIR',
    ])

env.PrependUnique(LIBPATH = [
    '.',
    '$BUILDDIR/policy/backend',
    '$BUILDDIR/policy/common',
    '$BUILDDIR/libfeaclient',
    '$BUILDDIR/xrl/interfaces',
    '$BUILDDIR/xrl/targets',
    '$BUILDDIR/libxipc',
    '$BUILDDIR/libxorp',
    '$BUILDDIR/libcomm',
    ])

env.AppendUnique(LIBS = [
    'xorp_policy_backend',
    'xorp_policy_common',
    'xorp_fea_client',
    'xst_bgp',
    'xst_fea_ifmgr_mirror',
    'xif_rib',
    'xif_finder_event_notifier',
    'xif_profile_client',
    'xif_fea_ifmgr_mirror',
    'xif_fea_ifmgr_replicator',
    'xorp_ipc',
    'xorp_core',
    'xorp_comm',
])

env.Replace(RPATH = [
    env.Literal(env['xorp_module_rpath'])
])

### libxorp_bgp

libxorp_bgp_env = env.Clone()

libxorp_bgp_srcs = [
	'aspath.cc',
	'attribute_manager.cc',
	'bgp_trie.cc',
	'bgp_varrw.cc',
	'bgp_varrw_export.cc',
	'crash_dump.cc',
	'damping.cc',
	'dump_iterators.cc',
	'internal_message.cc',
	'iptuple.cc',
	'local_data.cc',
	'next_hop_resolver.cc',
	'notification_packet.cc',
	'open_packet.cc',
	'packet.cc',
	'parameter.cc',
	'path_attribute.cc',
	'peer.cc',
	'peer_data.cc',
	'peer_handler.cc',
	'peer_list.cc',
	'plumbing.cc',
	'process_watch.cc',
	'profile_vars.cc',
	'rib_ipc_handler.cc',
	'route_queue.cc',
	'route_table_aggregation.cc',
	'route_table_base.cc',
	'route_table_cache.cc',
	'route_table_damping.cc',
	'route_table_decision.cc',
	'route_table_deletion.cc',
	'route_table_dump.cc',
	'route_table_fanout.cc',
	'route_table_filter.cc',
	'route_table_nhlookup.cc',
	'route_table_policy.cc',
	'route_table_policy_ex.cc',
	'route_table_policy_im.cc',
	'route_table_policy_sm.cc',
	'route_table_reader.cc',
	'route_table_ribin.cc',
	'route_table_ribout.cc',
	'socket.cc',
	'subnet_route.cc',
	'update_attrib.cc',
	'update_packet.cc',
	'xrl_target.cc',
	]

#libxorp_bgp = libxorp_bgp_env.SharedLibrary(target = 'libxorp_bgp', source = libxorp_bgp_srcs)

# XXX Static until ASPath and other objects are dealt with.
libxorp_bgp = libxorp_bgp_env.StaticLibrary(target = 'libxorp_bgp',
					    source = libxorp_bgp_srcs)

#env.Alias('install',
#          env.InstallLibrary('$libdir', libxorp_bgp))

### xorp_bgp

bgp_env = env.Clone()

bgp_env.PrependUnique(LIBS = [
    'xorp_bgp',
])

bgpsrcs = [
          'bgp.cc',
          'main.cc',
          ]

bgp = bgp_env.Program(target = 'xorp_bgp', source = bgpsrcs)
env.Alias('install', env.InstallProgram(env['xorp_moduledir'], bgp))

Default(libxorp_bgp, bgp)
